package no.ntnu.item.taxisystemgui.test.component;


public class TaxiClientSM extends no.ntnu.item.arctis.runtime.IStateMachine {


    protected no.ntnu.item.arctis.runtime.Scheduler scheduler;
    protected java.lang.String _stateMachineID;
    private no.ntnu.item.taxisystemgui.taxigui.TaxiGUI _b004;
    private no.ntnu.item.taxisystemgui.taxiclient.TaxiClient _b003;
    private static java.util.Hashtable _alias = new java.util.Hashtable();
    private static int sessionCount = 0;

    public TaxiClientSM(no.ntnu.item.arctis.runtime.Scheduler scheduler, java.lang.String sessionID, java.lang.String parentSessionID) {
        super(sessionID, parentSessionID);
        this.scheduler = scheduler;
        ++ sessionCount;
    }


    protected void registerAlias(java.lang.String alias, java.lang.String sessionID){
        if(alias==null) no.ntnu.item.arctis.runtime.Logger.getLogger().applicationError("Provided alias is null", null);
        if(sessionID==null) no.ntnu.item.arctis.runtime.Logger.getLogger().applicationError("Provided sessionID is null", null);
        if(_alias.containsKey(alias)) no.ntnu.item.arctis.runtime.Logger.getLogger().applicationError("A session with alias " + alias + " already exists.", null);
        _alias.put(alias, sessionID);
    }

    public static java.lang.String findSession(java.lang.String alias){
        if(alias==null) no.ntnu.item.arctis.runtime.Logger.getLogger().applicationError("Try to find session for null alias", null);
        String sessionID = (String) _alias.get(alias);
        if(sessionID==null) {
            if(!_alias.contains(alias)) {
        	       no.ntnu.item.arctis.runtime.Logger.getLogger().applicationError("Session map does not contain alias " + alias, null);
            } else {
                no.ntnu.item.arctis.runtime.Logger.getLogger().applicationError("Session map has a null entry for alias " + alias, null);
            }
        }
return sessionID;
    }

    public int getSessionCount(){
        return sessionCount;
    }

    public static java.util.Collection allSessions(){
        return _alias.values();
    }

    public int fireInitial(){
    }

    public int fire(java.lang.Object _sender, java.lang.Object sessionID, java.lang.String _signalID, java.lang.Object _data){
                return TRIGGER_UNKNOWN;
    }

    public int fireTimer(java.lang.String _timerID){
                return DISCARD_SIGNAL;
    }

    public java.lang.String getPartName(){
        return null;
    }

    public java.lang.String getId(){
        return this._stateMachineID;
    }
}
